1. Field of the Invention
The present invention relates to an image processing apparatus, method and storage medium.
2. Related Background Art
Conventional contour extraction methods include (1) a binarizing method of binarizing an image and tracing a boundary of an obtained binary pattern to extract a contour, (2) a tracing method of using a multivalued edge image, referring to the past tracing direction and tracing a local maximum edge pixel to extract the contour, (3) an area limiting method of detecting a boundary point of an object and a background in a pre-limited area to extract the contour, and (4) an active contour method of moving a closed curve surrounding an object to be cut out so that the predefined energy is minimized to extract the contour of the object.
The following method is known as the binarizing method. Specifically, a method described in Japanese Patent Publication No. 7-62873 comprises the steps of first binarizing an input image with an appropriate threshold value, removing noise from the obtained binary pattern, using an attended contour point as a center to search for the pixel in the vicinity in a clockwise or counterclockwise direction, detecting the next contour point, using the found contour point as a new attended point, and subsequently repeating the same processing to extract a contour pixel. In a method described in Japanese Patent Application Laid-Open No. 8-50655, an edge image constituted of an edge with one pixel width is first prepared. Specifically, a differential space filter or the like is applied to the input image to sharpen the image. If the edge width does not reach one pixel, a fine line processing is applied. After the edge image is prepared, in the same manner as in the method described in the Japanese Patent Publication No. 7-62873, the pixel in the vicinity is searched for in the clockwise or counterclockwise direction centering on the attended point to detect the next edge image.
In the tracing method, the multivalued edge image is used, and the pixel with the maximum edge strength is selected as the contour pixel from the pixels in the vicinity of the attended pixel. In the invention of Japanese Patent No. 2645995, on the assumption that it is natural to perform the next tracing in the same direction as the past tracing direction, the pixel edge strength along the past tracing direction is strongly weighted, the edge is traced, and the contour line is determined from a trace result.
In the area limiting method, the contour line is extracted only from a strip area which is set so as to include the contour line. In a method described in Japanese Patent Application Laid-Open No. 63-55101, an operator first roughly traces along the contour line. The strip area having a predetermined width is selected along the traced locus, and the image contour is determined from a tone value difference in the strip area. A method described in U.S. Pat. No. 5,617,487 (Japanese Patent Application Laid-Open No. 7-92650) comprises the steps of connecting at least two points designated on the contour line to form the strip area, and repeatedly executing a processing of detecting the contour point of the object in the width direction of the strip area while moving in the longitudinal direction of the strip area, to extract the contour line of the object.
In the active contour method, the contour line of the object is extracted by moving the closed curve surrounding the object to be cut out so that the predefined energy is minimized. For example, in xe2x80x9cSnakes: Active Contour Modelsxe2x80x9d authored by M. Kass, A. Witkin and D. Terzopoulos, International Journal of Computer Vision, Vol. 1, No. 4, pp. 321-331, 1988 is described a method of contracting/deforming the contour so that the sum of an energy applied in accordance with the shape of a contour model (internal energy), an energy applied in accordance with an image property (image energy), and an energy applied from the outside (external energy) is minimized.
The binarizing method has the following problems. Specifically, since the binarizing method is limited to an image from which the object can be extracted by a binarizing processing, for example, an image with a plain background, the method cannot be applied to a natural image. Even if the background is plain, in the binarizing processing of the natural image photographed under lighting conditions which cannot be managed, it is difficult to set the threshold value, and it is also difficult to automate the processing. After the binarizing processing, additional processings such as the fine line forming are usually necessary. Therefore, the processing system is complicated and enlarged in size, and it is difficult to realize speeding up.
The tracing method has the following problems. At the start of the tracing, since there is no clue to the tracing direction, the tracing is performed in a wrong direction in some cases. Since the object is traced without any target point, there is no guarantee that the tracing returns to a correct contour line at the time of tracing failure. Therefore, once the contour deviates, the tracing takes a winding course. When the tracing fails, the tracing is preferentially performed in the wrong direction, and continuously advances. Even when the correct contour line is returned, an error portion by the wrong tracing is emphasized.
The area limiting method has the following problems. Specifically, when the contour line is circular arc shaped, a plurality of short strip areas need to be set so that the contour line is uniformly included, which requires a very large number of processes. When the strip area can be curved, the operator is requested to trace along the contour line, or finely set reference points. Therefore, when the object has a complicated shape, a burden on the operator is large. In other words, the method is unsuitable for the object having a complicated shape.
Further, when the edge strength of the background running in the vicinity of the contour line included in the strip area is stronger than the edge strength of the true contour of the object, the background edge is wrongly detected. As a countermeasure, in the U.S. Pat. No. 5,617,487 is described a method which comprises the steps of setting a contour point determining weight distribution in the strip width direction of the strip area, and raising the edge detecting sensitivity in the vicinity of the center line of the strip area. In this method, the operator has to cautiously set the strip area so that the contour line is positioned in the vicinity of the center of the strip area. This is a complicated and laborious operation, and requires considerable skills. Of course, even when the weight distribution is set in this manner, in a case in which the edge strength of the background is strong, the background edge is wrongly detected. Therefore, this countermeasure is not perfect.
The active contour method has the following problems. Specifically, this method is sensitive to the precision of an initial value, that is, the initially set position of the closed curve. If the initial setting is bad, a correct contour is not converged. The calculation amount is usually enormous, and the speeding up is difficult. An energy function is defined on the assumption that the contour line is smooth, and the method is poor in extracting the contour line which changes in an acute angle.
An object of the present invention is to provide an image processing apparatus, method and storage medium to solve these problems.
Another object of the present invention is to provide an image processing apparatus, method and storage medium in which an image contour can highly precisely be extracted from a wide-range natural image including a complicated background with a simple operation at a high speed.
To achieve the above-described objects, a preferred embodiment of the present invention comprises a trace processing step of tracing a boundary of an image to be extracted among input images, and a limiting step of limiting a tracing direction when the trace processing step is performed.
According to another embodiment of the present invention, there is provided a contour extraction apparatus which comprises image input means for inputting an image, edge extraction means for extracting an edge from the input image inputted by the image input means, image display means for displaying the image, contour extraction interval setting means for designating a contour extraction interval from the input image, and contour extraction means for extracting a contour line from the input image. The contour extraction means comprises tracing means for tracing a pixel with a large edge strength from an edge point of a contour present in the contour extraction interval toward the other edge point, and mask processing means for successively applying a mask processing to a pixel in the vicinity centering on an attended point whose edge strength is to be compared in accordance with a positional relation of the attended point during contour tracing and an end point of the contour tracing.
Moreover, one embodiment of the present invention comprises an edge extracting step of extracting an edge from an input image, a contour extraction interval setting step of designating a contour extraction interval from the input image, and a contour extracting step of extracting a contour line from the input image. The contour extracting step comprises a tracing step of tracing a pixel with a large edge strength from an edge point of a contour present in the contour extraction interval toward the other edge point, and a mask processing step of successively applying a mask processing to the pixel in the vicinity centering on an attended point whose edge strength is to be compared in accordance with a positional relation of the attended point during contour tracing and an end point of the contour tracing.
Further, one embodiment of the present invention comprises a contour extraction interval setting step of setting a contour extraction interval, an edge point setting step of setting a start point and an end point for contour tracing in the contour extraction interval, a positional relation calculating step of calculating a positional relation between an attended point during the contour tracing and the end point, a mask processing step of applying a mask processing to the attended point in accordance with the obtained positional relation, a searching step of searching for a pixel with a maximum edge strength in the pixel in the vicinity of the attended point, an attended point renewing step of setting the pixel with the maximum edge strength as the next attended point, and a determining step of determining whether or not the attended point reaches the end point and repeating the positional relation calculating step, the mask processing step, the searching step, the attended point renewing step and the determining step until the attended point reaches the end point.
The present invention relates to an image processing apparatus, an image processing method and a storage medium which have inventive functions.